package com.baixun.gasadmin.controller;


import com.baixun.gascommon.utils.R;
import com.baixun.gasentity.dto.LoginDto;
import com.baixun.gasentity.validate.Logincharge;
import com.baixun.gassystem.service.SysUserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.hibernate.mapping.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 登录认证接口处理类
 */
@RestController
@RequestMapping("/user")
@Api(value = "登录认证接口管理模块类",tags = "登录模块")
public class LoginController {

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public R Login(@RequestBody  @Validated(Logincharge.class) LoginDto loginDto) throws Exception {
         return  R.success(sysUserService.Login(loginDto));
    }

    /**
     * 获取验证码接口
     * @return 包含验证码的响应内容
     */
    @ApiOperation(value = "获取验证码", notes = "调用此接口获取验证码")
    @GetMapping("/verificationCode")
    public R getVerificationCode() {
        return R.success(sysUserService.getVerificationCode());
    }




//    @ApiOperation("获取用户信息")
//    @GetMapping("/info")
//    public R info() {
//        return sysUserService.info();
//    }


    @ApiOperation("退出当前用户")
    @GetMapping("/logout")
    public R logout()   {
        return sysUserService.logout();
    }


//    @ApiOperation("忘记密码接口")
//    @GetMapping("/find/password")
//    public R findPassword(@RequestBody LoginDto loginDto) {
//        return sysUserService.findPassword(loginDto);
//    }

//    @ApiOperation("md5密码加密")
//    @GetMapping("/Md5/password")
//    public R Md5Password(String password) {
//        return sysUserService.Md5Password(password);
//    }


//    @ApiOperation("删除用户信息")
//    @GetMapping("/delete")
//    public R delete() {
//        return sysUserService.delete();
//    }



}
